import {
  ADD_WORK,
  DELET_WORK,
  SHOW_ADD_WORK_MODAL,
  HIDE_ADD_WORK_MODAL,
  GET_WORKS
} from "../constants/workToDo";

const INIT_STATE = {
  showAddWorkModal: false,
  works:[]
};

export default function workToDo(state = INIT_STATE, action) {
  switch (action.type) {
    case SHOW_ADD_WORK_MODAL:
      return { ...state, showAddWorkModal: true };
    case HIDE_ADD_WORK_MODAL:
      return { ...state, showAddWorkModal:false};
    case ADD_WORK:
      return { ...state,showAddWorkModal:false};
    case GET_WORKS:
      return {...state,works:action.payload};
    case DELET_WORK:
      return { ...state };
    default:
      return state;
  }
}
